package edu.demo.recommend.common;


import java.security.MessageDigest;
import java.util.Base64;

/**
 * MD5的工具类
 * @author hb
 */
public class MD5Utils {

    public static String md5(String str){
        try{
            MessageDigest instance = MessageDigest.getInstance("MD5");
            Base64.Encoder encoder = Base64.getEncoder();
            byte[] encode = encoder.encode(instance.digest(str.getBytes("utf-8")));
            return new String(encode,"utf-8");
        }catch (Exception e) {
             throw new RuntimeException(e);
        }

    }
}
